<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <script>
            /* 
                内存泄漏

                低版本IE浏览器。
             */
             window.onload = function(){
                 /* var oDiv = document.getElementById("div1");
                 oDiv.onclick = function(){
                     alert(oDiv.id);
                     console.log(oDiv);
                 } */

                 /* var oDiv = document.getElementById("div1");
                 var id = oDiv.id;
                 oDiv.onclick = function(){
                     alert(id);
                 }
                 oDiv = null; */


                 var oDiv = document.getElementById("div1");
                 
                 oDiv.onclick = function(){
                     alert(oDiv.id);
                 }
                
                window.onunload = function(){
                    oDiv.onclick = null;
                    oDiv = null;
                }
             }
        </script>
    </head>
    <body>
        <div id = 'div1'>div文本</div>
    </body>
</html>